<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.org/ui">

    <ui:composition template="/resources/templates/template_site.xhtml">

        <ui:define name="content">
             

                <p:growl id="growl" showDetail="true" showSummary="false"/>                
                <p:wizard widgetVar="wiz" flowListener="#{itemController.onFlowProcess}">                    
                    <p:tab id="item" title="Item">
                        <p:panel header="#{bundle.CreateItemTitle}">                            
                            <p:messages showDetail="true" autoUpdate="true" showSummary="false"/>
                            <p:panelGrid columns="2">                                                                
                                <h:outputLabel value="#{bundle.CreateItemLabel_nomitem}" for="nomitem" />
                                <p:inputText id="nomitem" value="#{itemController.selected.nomitem}" title="#{bundle.CreateItemTitle_nomitem}" required="true" requiredMessage="#{bundle.CreateItemRequiredMessage_nomitem}"/>                                
                                <h:outputLabel value="#{bundle.CreatePrixLabel_somme}" for="somme" />
                                <p:inputText id="somme" value="#{itemController.somme}" title="#{bundle.CreatePrixTitle_somme}" required="true" requiredMessage="#{bundle.CreatePrixRequiredMessage_somme}"/>                    
                                <h:outputLabel value="#{bundle.CreateItemLabel_quantiteitem}" for="quantiteitem" />
                                <p:inputText id="quantiteitem" value="#{itemController.selected.quantiteitem}" title="#{bundle.CreateItemTitle_quantiteitem}" required="true" requiredMessage="#{bundle.CreateItemRequiredMessage_quantiteitem}"/>
                                <h:outputLabel value="#{bundle.CreateItemLabel_seuilmin}" for="seuilmin" />
                                <p:inputText id="seuilmin" value="#{itemController.selected.seuilmin}" title="#{bundle.CreateItemTitle_seuilmin}" required="true" requiredMessage="#{bundle.CreateItemRequiredMessage_seuilmin}"/>
                                <h:outputLabel value="#{bundle.CreateItemLabel_quantitecommande}" for="quantitecommande" />
                                <p:inputText id="quantitecommande" value="#{itemController.selected.quantitecommande}" title="#{bundle.CreateItemTitle_quantitecommande}" required="true" requiredMessage="#{bundle.CreateItemRequiredMessage_quantitecommande}"/>
                                <h:outputLabel value="#{bundle.CreateItemLabel_desccourte}" for="desccourte" />
                                <p:inputText id="desccourte" value="#{itemController.selected.desccourte}" title="#{bundle.CreateItemTitle_desccourte}" />
                                <h:outputLabel value="#{bundle.CreateItemLabel_descdetail}" for="descdetail" />
                                <p:inputTextarea id="descdetail" value="#{itemController.selected.descdetail}" title="#{bundle.CreateItemTitle_descdetail}" />
                                <h:outputLabel value="#{bundle.CreateItemLabel_category}" for="category" />                                
                                <p:selectOneMenu id="category" value="#{itemController.selected.category}" title="Category" required="true" requiredMessage="#{bundle.CreateItemRequiredMessage_category}">  
                                    <f:selectItems value="#{categoryController.itemsAvailableSelectOne}"/> 
                                </p:selectOneMenu>            
                                <h:outputLabel value="#{bundle.CreatePhotosLabel_photo}" for="photo" />
                                <p:fileUpload label="Choisir" cancelLabel="Annuler" uploadLabel="Charger" fileUploadListener="#{itemController.processFileUpload}" mode="advanced"  
                                              allowTypes="/(\.|\/)(gif|jpeg|png)$/" sizeLimit="1000000" id="photo"/>                                                           
                            </p:panelGrid>                                                        
                        </p:panel>
                    </p:tab>

                    <p:tab id="fournisseur" title="Fournisseur" >                         
                        <p:panel header="#{bundle.CreateFournisseurTitle}">
                            <p:tabView id="tab" effect="fade" effectDuration="normal" cache="false" dynamic="true" >
                                
                                <p:ajax event="tabChange" listener="#{itemController.onTabChange}" immediate="true" update="A,B"/>  
                                
                                <p:tab title="Choisir un Fournisseur"> 
                                    <p:messages showDetail="true" autoUpdate="true" showSummary="false" />                                   
                                    <p:panelGrid columns="2" id="A" rendered="#{!itemController.chooseFour}">
                                        <h:outputText value="Choisir un fournisseur: " />  
                                        <p:selectOneMenu value="#{itemController.fournisseur}">  
                                            <f:selectItem itemLabel="--select---"/>
                                            <f:selectItems value="#{itemController.listFournisseur}" var="fournisseur" itemLabel="#{fournisseur.nomfour}"/>  
                                        </p:selectOneMenu>
                                    </p:panelGrid>
                                </p:tab>                                
                                <p:tab title="Ajouter un Nouveau Fournisseur">
                                    <p:messages showDetail="true" autoUpdate="true" showSummary="false" />
                                    <p:panelGrid columns="2" id="B" rendered="#{itemController.chooseFour}">
                                        <h:outputLabel value="#{bundle.CreateFournisseurLabel_telfour}" for="telfour" />
                                        <p:inputMask mask="(999) 99 999 999" id="telfour" value="#{itemController.fournisseur.telfour}" title="#{bundle.CreateFournisseurTitle_telfour}" requiredMessage="#{bundle.CreateFournisseurRequiredMessage_telfour}"/>
                                        <h:outputLabel value="#{bundle.CreateFournisseurLabel_siteweb}" for="siteweb" />
                                        <p:inputText id="siteweb" value="#{itemController.fournisseur.siteweb}" title="#{bundle.CreateFournisseurTitle_siteweb}" validator="adressValidator"/>
                                        <h:outputLabel value="#{bundle.CreateFournisseurLabel_nomfour}" for="nomfour" />
                                        <p:inputText id="nomfour" value="#{itemController.fournisseur.nomfour}" title="#{bundle.CreateFournisseurTitle_nomfour}" requiredMessage="#{bundle.CreateFournisseurRequiredMessage_nomfour}"/>
                                        <h:outputLabel value="#{bundle.CreateFournisseurLabel_adressefour}" for="adressefour" />
                                        <p:inputText id="adressefour" value="#{itemController.fournisseur.adressefour}" title="#{bundle.CreateFournisseurTitle_adressefour}" requiredMessage="#{bundle.CreateFournisseurRequiredMessage_adressefour}"/>                                        
                                    </p:panelGrid>
                                </p:tab>                                                                  
                            </p:tabView>                             
                        </p:panel>
                    </p:tab>

                    <p:tab id="caracteristique" title="Caracteristics">
                        <p:panel header="#{bundle.CreateCaracteristiqueTitle}"> 
                            <p:messages showDetail="true" autoUpdate="true" showSummary="false" />
                            <p:panelGrid id="carac" columns="2">
                                <h:outputLabel value="#{bundle.CreateCaracteristiqueLabel_nomcarac}" for="nomcarac" />
                                <p:inputText id="nomcarac" value="#{itemController.caracteristique.nomcarac}" title="#{bundle.CreateCaracteristiqueTitle_nomcarac}"/>
                                <h:outputLabel value="#{bundle.CreateCaracteristiqueLabel_decription}" for="decription" />
                                <p:inputText id="decription" value="#{itemController.caracteristique.decription}" title="#{bundle.CreateCaracteristiqueTitle_decription}"/>                                                                
                            </p:panelGrid>
                            <br />
                            <p:commandButton value="Add Caracteristic" actionListener="#{itemController.addCaracteristic()}" update="carac" process="@parent"/>
                        </p:panel>
                    </p:tab>
                    
                    <p:tab id="confirm" title="Confirmation">
                        <p:panel header="Confirmation">			
                            <p:panelGrid id="confirmation" columns="6">                                        
                                <h:outputText value="#{bundle.CreateItemLabel_nomitem}" />
                                <h:outputText value="#{itemController.selected.nomitem}"/>

                                <h:outputText value="#{bundle.CreatePrixLabel_somme}" />
                                <h:outputText value="#{itemController.somme}"/>  

                                <h:outputText value="#{bundle.CreateItemLabel_quantiteitem}"/>
                                <h:outputText value="#{itemController.selected.quantiteitem}"/>

                                <h:outputText value="#{bundle.CreateItemLabel_seuilmin}"/>
                                <h:outputText value="#{itemController.selected.seuilmin}"/>

                                <h:outputText value="#{bundle.CreateItemLabel_quantitecommande}"/>
                                <h:outputText value="#{itemController.selected.quantitecommande}"/>

                                <h:outputText value="#{bundle.CreateItemLabel_desccourte}"/>
                                <h:outputText value="#{itemController.selected.desccourte}"/>

                                <h:outputText value="#{bundle.CreateItemLabel_descdetail}"/>
                                <h:outputText value="#{itemController.selected.descdetail}"/>

                                <h:outputText value="#{bundle.CreateItemLabel_category}"/>
                                <h:outputText value="#{itemController.selected.category}"/>
                                
                                <h:outputLabel value="#{bundle.CreateFournisseurLabel_telfour}"/>
                                <h:outputLabel value="#{itemController.fournisseur.telfour}" />
                                <h:outputLabel value="#{bundle.CreateFournisseurLabel_siteweb}"/>
                                <h:outputLabel value="#{itemController.fournisseur.siteweb}"/>
                                <h:outputLabel value="#{bundle.CreateFournisseurLabel_nomfour}"/>
                                <h:outputLabel value="#{itemController.fournisseur.nomfour}"/>
                                <h:outputLabel value="#{bundle.CreateFournisseurLabel_adressefour}"/>
                                <h:outputLabel value="#{itemController.fournisseur.adressefour}"/>                                        

                            </p:panelGrid>
                            <p:commandButton value="Submit" action="#{itemController.create()}" update="growl" process="@parent"/>
                        </p:panel>
                    </p:tab>
                </p:wizard>

             
        </ui:define>
    </ui:composition>

</html>
